/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * POS_ViewCart.java
 *
 * Created on Apr 4, 2011, 7:13:38 PM
 */

package POS_Source;

import Cart.Cart;
import DTO.Item;
import POS_Controller.POSController;
import Utilities.MoneyFormatter;
import java.util.ListIterator;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author edaype
 */
public class POS_ViewCart extends javax.swing.JPanel {

    private Cart cart;
    private POSController controller;
    private static final String[] columnNames = new String [] {"Name", "Quantity", "Price"};
    private MoneyFormatter moneyFormatter;

    /** Creates new form POS_MainOut
     * @param control
     * @param cart 
     */
    public POS_ViewCart(POSController control) {
        initComponents();
        controller = control;
        this.cart = control.getSessionManager().getCart();
        moneyFormatter = new MoneyFormatter();
        customInit();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        ButtonLayout = new javax.swing.JPanel();
        CheckoutButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        IncreaseButton = new javax.swing.JButton();
        DeleteButton = new javax.swing.JButton();
        DecreaseButton = new javax.swing.JButton();
        DiscountButton = new javax.swing.JButton();
        OverrideButton = new javax.swing.JButton();
        AddBagButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        SubTotalAmount = new javax.swing.JLabel();
        TaxAmount = new javax.swing.JLabel();
        TotalAmount = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        DiscountAmount = new javax.swing.JLabel();
        StoreCardDiscountAmount = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jTable1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Name", "Make", "Model", "Price", "Quantity"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);

        ButtonLayout.setBackground(new java.awt.Color(255, 255, 255));

        CheckoutButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        CheckoutButton.setText("Checkout");
        CheckoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CheckoutButtonActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 60));
        jLabel1.setText("Cart Review");

        javax.swing.GroupLayout ButtonLayoutLayout = new javax.swing.GroupLayout(ButtonLayout);
        ButtonLayout.setLayout(ButtonLayoutLayout);
        ButtonLayoutLayout.setHorizontalGroup(
            ButtonLayoutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtonLayoutLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 438, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 120, Short.MAX_VALUE)
                .addComponent(CheckoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27))
        );
        ButtonLayoutLayout.setVerticalGroup(
            ButtonLayoutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtonLayoutLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ButtonLayoutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(CheckoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        IncreaseButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        IncreaseButton.setText("+");
        IncreaseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                IncreaseButtonActionPerformed(evt);
            }
        });

        DeleteButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        DeleteButton.setText("Delete");
        DeleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteButtonActionPerformed(evt);
            }
        });

        DecreaseButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        DecreaseButton.setText("-");
        DecreaseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DecreaseButtonActionPerformed(evt);
            }
        });

        DiscountButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        DiscountButton.setText("Apply Discount");
        DiscountButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DiscountButtonActionPerformed(evt);
            }
        });

        OverrideButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        OverrideButton.setText("Override Price");
        OverrideButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OverrideButtonActionPerformed(evt);
            }
        });

        AddBagButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        AddBagButton.setText("AddBag");
        AddBagButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddBagButtonActionPerformed(evt);
            }
        });

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        jLabel2.setText("Subtotal");

        jLabel3.setText("Tax");

        jLabel4.setText("________________________________");

        jLabel5.setText("Total");

        SubTotalAmount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        TaxAmount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        TotalAmount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        jLabel6.setText("Total Discount");

        DiscountAmount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        StoreCardDiscountAmount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        jLabel7.setText("Storecard Discount");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
                                .addGap(14, 14, 14)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(TaxAmount, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(SubTotalAmount, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(DiscountAmount, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE))
                            .addComponent(TotalAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(StoreCardDiscountAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(StoreCardDiscountAmount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel6)
                    .addComponent(DiscountAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(SubTotalAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(TaxAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(TotalAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 627, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(AddBagButton, 0, 0, Short.MAX_VALUE)
                            .addComponent(IncreaseButton, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                            .addComponent(DecreaseButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(DeleteButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(ButtonLayout, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(OverrideButton, 0, 0, Short.MAX_VALUE)
                            .addComponent(DiscountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 149, Short.MAX_VALUE))
                        .addGap(222, 222, 222)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(84, 84, 84)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(IncreaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(DecreaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(DeleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(AddBagButton, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(OverrideButton, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(DiscountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(ButtonLayout, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void IncreaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IncreaseButtonActionPerformed
        int selected = jTable1.getSelectedRow();
        if (selected>=0){
            cart.increaseQuantity(selected);
            jTable1.setValueAt(cart.getItemsInCart().get(selected).getQty(), selected, 1);
            setTotals();
            jTable1.repaint();
            controller.refresh();
        }
    }//GEN-LAST:event_IncreaseButtonActionPerformed

    private void DecreaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DecreaseButtonActionPerformed
        int selected = jTable1.getSelectedRow();
        if (selected>=0){
            cart.decreaseQuantity(selected);
            jTable1.setValueAt(cart.getItemsInCart().get(selected).getQty(), selected, 1);
            setTotals();
            jTable1.repaint();
            controller.refresh();
        }
    }//GEN-LAST:event_DecreaseButtonActionPerformed

    private void DeleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteButtonActionPerformed
        int selected = jTable1.getSelectedRow();
        if (selected>=0)
            cart.removeItem(selected);
        controller.CartScreen();
    }//GEN-LAST:event_DeleteButtonActionPerformed

    private void CheckoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CheckoutButtonActionPerformed
        controller.PaymentSelectScreen();
    }//GEN-LAST:event_CheckoutButtonActionPerformed

    private void DiscountButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DiscountButtonActionPerformed
        controller.ClerkDiscountScreen();
    }//GEN-LAST:event_DiscountButtonActionPerformed

    private void OverrideButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OverrideButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_OverrideButtonActionPerformed

    private void AddBagButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddBagButtonActionPerformed
        controller.applyDiscount();
    }//GEN-LAST:event_AddBagButtonActionPerformed

    public final void customInit(){
        initTable();
        setTotals();
        if (!controller.getSessionManager().isClerkLoggedIn()){
            OverrideButton.setVisible(false);
            DiscountButton.setVisible(false);
        }

    }

    private void initTable(){
        ListIterator<Item> iter = cart.getItemsInCart().listIterator();
        DefaultTableModel model = new DefaultTableModel(columnNames, 0);

        while (iter.hasNext()){
            Item item = iter.next();
            Vector row = new Vector();
            row.add(item.getName());
            row.add(item.getQty());
            row.add(moneyFormatter.format(item.getSoldPrice()));
            model.addRow(row);
            if (item.getDiscountAmount() > 0.0 || controller.getSessionManager().getLoggedIn()){
                
            }
        }

        jTable1.setModel(model);

        TableColumn column = null;
        column = jTable1.getColumnModel().getColumn(0);
        column.setPreferredWidth(375); //third column is bigger
        column = jTable1.getColumnModel().getColumn(1);
        column.setPreferredWidth(25);
        column = jTable1.getColumnModel().getColumn(2);
        column.setPreferredWidth(50);

        jTable1.setRowHeight(40);

        jTable1.setColumnSelectionAllowed(false);
        jTable1.setRowSelectionAllowed(true);
    }

    private void setTotals(){
        StoreCardDiscountAmount.setText(moneyFormatter.format(cart.getStoreCardDiscount()));
        DiscountAmount.setText(moneyFormatter.format(cart.getTotalDiscount()));
        SubTotalAmount.setText(moneyFormatter.format(cart.getSubtotal()));
        TaxAmount.setText(moneyFormatter.format(cart.getTaxAmount()));
        TotalAmount.setText(moneyFormatter.format(cart.getTotal()));
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddBagButton;
    private javax.swing.JPanel ButtonLayout;
    private javax.swing.JButton CheckoutButton;
    private javax.swing.JButton DecreaseButton;
    private javax.swing.JButton DeleteButton;
    private javax.swing.JLabel DiscountAmount;
    private javax.swing.JButton DiscountButton;
    private javax.swing.JButton IncreaseButton;
    private javax.swing.JButton OverrideButton;
    private javax.swing.JLabel StoreCardDiscountAmount;
    private javax.swing.JLabel SubTotalAmount;
    private javax.swing.JLabel TaxAmount;
    private javax.swing.JLabel TotalAmount;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables

}
